package com.gs.SynPatrolRep.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.gs.SynPatrolRep.activity.MainActivity;
import com.gs.SynPatrolRep.activity.palBill.PalBillSiteActivity;
import com.gs.SynPatrolRep.constant.AllConstants;
import com.gs.SynPatrolRep.signalr.SignalRCode;

public class NotificationReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        String pushType = intent.getStringExtra(AllConstants.WHAT);
        if (pushType != null) {
            Intent intentGo = new Intent();
            if (pushType.equals(SignalRCode.PUSH_EVENT)) {
                intentGo.setClass(context, MainActivity.class);
                intentGo.putExtra(AllConstants.WHAT, 2);
                intentGo.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
            } else {
                intentGo.setClass(context, PalBillSiteActivity.class);
                intentGo.putExtra(AllConstants.ID, intent.getStringExtra(AllConstants.ID));
                intentGo.putExtra(AllConstants.WHAT, pushType.equals(SignalRCode.PUSH_PATROL) ? 0 : 2);
            }
            context.startActivity(intentGo);
        }
    }
}
